package com.springboot.study.tests;

import com.alibaba.fastjson.JSONObject;
import com.springboot.study.utils.LocalDateUtils;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * @Author: guodong
 * @Date: 2021/4/26 10:36
 * @Version: 1.0
 * @Description:
 */
public class Test {

    public static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");


    public static void main(String[] args) throws Exception{
        List<UserTest> userList = new ArrayList<>();
        UserTest u1 = new UserTest(12, "guoguo", simpleDateFormat.parse("2021-12-23"));
        UserTest u2 = new UserTest(12, "guoguo333",simpleDateFormat.parse("2021-12-23"));
        userList.add(u1);
        userList.add(u2);
        Map<LocalDate, UserTest> map = userList
                .stream().collect(Collectors.toMap(lt -> LocalDateUtils.date2LocalDate(lt.getBirth()), lt -> lt, (a,b)->a));
        System.out.println(map);
    }

}